package org.hhchat.leetcode.string;

/**
 * Created this one by HMH on 2017/10/1.
 */
public class code686_easy {
    static class Solution {
        public int repeatedStringMatch(String A, String B) {
            StringBuilder stringBuilder = new StringBuilder(A);
            if (A.length() > B.length() && A.contains(B)) {
                return 1;
            }
            int count = 1;
            int n = B.length() / A.length();
            for(int i=0;i<n-1;i++) {
                stringBuilder.append(A);
                count++;
            }
            for(int i=0;i<3;i++) {
                if (stringBuilder.toString().contains(B)) {
                    return count;
                }
                stringBuilder.append(A);
                count++;
            }
            return -1;
        }
    }
    public static void main(String[] args){
        Solution solution = new Solution();
        System.out.println(solution.repeatedStringMatch("abcd","cdabcdab"));
    }

}
